﻿/* Tag class. */
var JsComment = function () {

};
JsComment.prototype.InsertComment = function (PostId, ParentId, Comment, Email, Name, Website, Validate) {
    var result = true;
    var jsonStr = "{PostId:" + PostId + ",ParentId:" + ParentId + ",Comment:'" + Comment + "',Email:'" + Email + "',Name:'" + Name + "',Website:'" + Website + "',Validate:" + Validate + "}";
    $.ajax({
        type: "POST",
        url: "/Modules/Posts/WS/AddComment.asmx/AddPostComment",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: jsonStr,
        async: false,
        success: function (msg) {
            if (msg.d != '') {
                result = true;
            } else {
                result = false;
            }
        },
        error: function () {
            alert("Error2!");
            result = false;
        }
    });
    return result;
};

JsComment.prototype.ValidateCaptcha = function (Validate) {
    var result = "";
    var jsonStr = "{Validate:" + Validate + "}";
    $.ajax({
        type: "POST",
        url: "/Modules/Posts/WS/AddComment.asmx/ValidateCaptcha",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: jsonStr,
        async: false,
        success: function (msg) {
            result = msg.d;
        },
        error: function () {
            alert("Error2!");
        }   
    });
    return result;

};
JsComment.prototype.Delete = function (Id) {
    var result = "";
    var jsonStr = "{Id:" + Id + "}";
    $.ajax({
        type: "POST",
        url: "/Modules/Posts/WS/AddComment.asmx/DeleteComment",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: jsonStr,
        async: false,
        success: function (msg) {
            result = msg.d;
        },
        error: function () {
            alert("Error2!");
        }
    });
    return result;

};

/* Usage. */
